import http from '@ohos.net.http'
import { Response } from './Response';
import { request } from './Request';
import { ContentType, defContentType } from '../util/HttpConfig';
import HashMap from '@ohos.util.HashMap';

export function PostForm<T>(url: string, extraData?: Object, headerData?: HashMap<string, Object>): Promise<Response<T>> {
  return request(url, http.RequestMethod.POST, ContentType.FORM, extraData, headerData);
}

export function PostJson<T>(url: string, extraData?: Object, headerData?: HashMap<string, Object>): Promise<Response<T>> {
  return request(url, http.RequestMethod.POST, ContentType.JSON, extraData, headerData);
}

export function Post<T>(url: string, extraData?: Object, headerData?: HashMap<string, Object>): Promise<Response<T>> {
  return request(url, http.RequestMethod.POST, defContentType, extraData, headerData);
}

export function Get<T>(url: string, extraData?: Object, headerData?: HashMap<string, Object>): Promise<Response<T>> {
  return request(url, http.RequestMethod.GET, ContentType.JSON, extraData, headerData);
}